package cn.xiaobai.utils;

import java.net.URL;
import java.nio.file.Paths;

/**
 * @Author yangdaji
 * @Date 2023/12/20
 * @PackageName cn.xiaobai.utils
 * @ClassName SourceUtils
 */
public class SourceUtils {

    private static final String PREFIX = "fxml/";
    private static final String SUFFIX = ".fxml";

    public static URL getFxmlSource(String fileName) {
        URL fxmlPath = ClassLoader.getSystemClassLoader().getResource(PREFIX);
        if (fxmlPath != null) {
            try {
                return Paths.get(Paths.get(fxmlPath.toURI()).toString(), fileName + SUFFIX).toUri().toURL();
            } catch (Exception e) {
            }
        }
        return null;
    }
}
